package ar.uade.fain.ai.tpo.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class ResultSetExtractorAdapter<T> implements ResultSetExtractor<T> {
	
	public final RowMapper<T> rowMapper;

	public ResultSetExtractorAdapter(final RowMapper<T> rowMapper) {
		super();
		this.rowMapper = rowMapper;
	}

	@Override
	public List<T> extraer(final ResultSet rs) throws SQLException {
		ArrayList<T> arrayList = new ArrayList<T>();
		while (rs.next()) {
			arrayList.add(rowMapper.map(rs));
		}
		return arrayList;
	}

}
